package yijy.threadExample;

/**
 * Created by yijy on 2017/7/26.
 * join()方法，等待线程阻塞
 *  当前线程可以调用另一个线程的join()方法，当前线程由运行转为阻塞状态，另一个运行至结束才恢复运行当前线程。
 */
public class ThreadTest4 implements Runnable{
    public static void main(String[] args) {
        System.out.println(Thread.currentThread().getName()+":main start");
        ThreadTest4 test4= new ThreadTest4();
        Thread t1 = new Thread(test4);
        Thread t2 = new Thread(test4);
        t1.start();
        try {
            t1.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName()+":111111111111");
        t2.start();
        System.out.println(Thread.currentThread().getName()+":main end");
    }
    @Override
    public void run() {
        for(int i=0;i<50;i++){
            System.out.println(Thread.currentThread().getName()+":"+i);
        }
    }
}
